import { HTTP } from '../../util/http'

class Community extends HTTP {
  list() {
    const url = 'MomentGroup/selectMomentGroupList'
    return new Promise((resolve, reject) => {
      this.request({
        url: url,
        newURL: true,
        success: resolve
      })
    })
  }

  // 删除动态
  dellent(data){
    const url='Moments/deleteMoment'
    return new Promise((resolve, reject) => {
      this.request({
        url:url,
        newURL: true,
        success: resolve,
        method:'POST',
        urlData: data,  
      })
    })
  }

  // 关注人
 guanzhu(data) {
   const url="MyFans/save"
   return new Promise((resolve, reject) => {
    this.request({
      url: url,
      newURL: true,
      success: resolve,
      data,
      method: 'POST'    
    })
  })
 }

// 取消关注人的
noGuanzhu(data) {
  const url="MyFans/unfollowYou"
  return new Promise((resolve, reject) => {
   this.request({
     url: url,
     newURL: true,
     success: resolve,
     urlData: data,
     method: 'POST'    
   })
 })
}

  myJoinList() {
    const url = 'MomentGroup/selectMyJoinMomentGroup'
    return new Promise((resolve, reject) => {
      this.request({
        url: url,
        newURL: true,
        success: resolve
      })
    })
  }

  publishMoment(data = {}) {
    const url = 'Moments/save'
    return new Promise((resolve, reject) => {
      this.request({
        data,
        url: url,
        newURL: true,
        success: resolve,
        method: 'POST'
      })
    })
  }

  momentList(data) {
    const url = 'Moments/selectAllMoment'
    return new Promise((resolve, reject) => {
      this.request({
        data,
        url: url,
        newURL: true,
        success: resolve,
        method: 'POST'
      })
    })
  }

  momentLike(data) {
    const url = 'MomentPraise/praise'
    return new Promise((resolve, reject) => {
      this.request({
        url: url,
        newURL: true,
        urlData: data,
        success: resolve,
        method: 'POST'
      })
    })
  }
  // 取消赞
  noMomentLike(data) {
    const url = 'MomentPraise/cancelPraise'
    return new Promise((resolve, reject) => {
      this.request({
        url: url,
        newURL: true,
        urlData: data,
        success: resolve,
        method: 'POST'
      })
    })
  }



  momentComment(data) {
    const url = 'MomentComment/selectMomentComment'
    return new Promise((resolve, reject) => {
      this.request({
        url: url,
        newURL: true,
        data,
        success: resolve,
        method: 'POST'
      })
    })
  }

  momentDetail(data) {
    const url = 'Moments/selectMomentDetail'
    return new Promise((resolve, reject) => {
      this.request({
        url: url,
        newURL: true,
        urlData: data,
        success: resolve,
        method: 'POST'
      })
    })
  }

  monmentComment(data) {
    const url = 'MomentComment/selectMomentComment'
    return new Promise((resolve, reject) => {
      this.request({
        url: url,
        newURL: true,
        urlData: data,
        success: resolve,
        method: 'POST'
      })
    })
  }

  // 评论动态
  commnet(data) {
    const url = 'MomentComment/comment'
    return new Promise((resolve, reject) => {
      this.request({
        url: url,
        newURL: true,
        data,
        success: resolve,
        method: 'POST'
      })
    })
  }
/**
 * 添加关注
 */
  follow(data) {
    const url = 'MomentGroup/saveJoinMomentGroup'
    return new Promise((resolve, reject) => {
      this.request({
        url: url,
        newURL: true,
        data,
        success: resolve,
        method: 'POST'
      })
    })
  }
// 取消关注
noFollow(data) {
  const url='MomentGroup/deleteJoinMomentGroup'
  return new Promise((resolve, reject)=>{
    this.request({
      url: url,
      newURL: true,
      urlData: data,
      success: resolve,
      method: 'POST'
    })
  })
}
// 圈子详情
Moments(data) {
  let url='Moments/selectRecommendMoments'
  return new Promise((resolve, reject)=>{
    this.request({
      url: url,
      newURL: true,
      data,
      success: resolve,
      method: 'POST'
    })
  })
}

// 收藏和取消收藏
   nocancelCollection(data) {
    const url = 'MomentCollection/cancelCollection'
    return new Promise((resolve, reject) => {
      this.request({
        url: url,
        newURL: true,
        urlData: data,
        success: resolve,
        method: 'POST'
      })
    })
  }
  // 收藏功能
  cancelCollection(data) {
    const url = 'MomentCollection/save'
    return new Promise((resolve, reject) => {
      this.request({
        url: url,
        newURL: true,
        urlData: data,
        success: resolve,
        method: 'POST'
      })
    })
  }
}

export default new Community()
